package com.webapp.model;

import java.sql.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Comment {
	
	private int commentId;
	private String date;
	private String content;
	private int author;
	public int postId;
	
	public Comment(int post, String newContent, int newAuthor){
		commentId = new Double( Math.random() * 100000 ).intValue();
		content = newContent;
		author = newAuthor;
		postId = post;
		
		DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		Calendar cal = Calendar.getInstance();
		
		date = dateFormat.format(cal.getTime());
	}
	
	public Comment(int post, String newContent, int newAuthor, String dater, int comment){
		commentId = comment;
		date = dater;
		content = newContent;
		author = newAuthor;
		postId = post;
	}
	
	public Comment(int post, String newContent, int newAuthor, int comment){
		commentId = comment;
		DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		Calendar cal = Calendar.getInstance();
		date = dateFormat.format(cal.getTime());
		content = newContent;
		author = newAuthor;
		postId = post;
	}

	public int getCommentId(){return this.commentId;}
	public String getDate(){return this.date;}
	public String getContent(){return this.content;}
	public int getAuthor(){return this.author;}
	public int getPostId(){return this.postId;}
	
	public void setCommentId(int newId){this.commentId = newId;}
	public void setDate(String newDate){this.date = newDate;}
	public void setContent(String newContent){this.content = newContent;}
	public void setAuthor(int newAuthor){this.author = newAuthor;}
	public void setPostId(int id){this.postId = id;}
}
